package com.kma.summer2012.client.view.requests;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import com.kma.summer2012.shared.model.UICrumbsRequest;

public class ShowRequest extends Request {
    @UiTemplate("ShowRequest.ui.xml")
    interface ShowRequestUiBinder extends UiBinder<HTMLPanel, Request> {
    }

    private static ShowRequestUiBinder showRequestUibinder = GWT.create(ShowRequestUiBinder.class);

    public ShowRequest() {
        super(showRequestUibinder);

        this.title.setText(constants.showRequest());
        this.saveButton.setEnabled(false);
        this.editButtonManager.setVisible(false);
        this.editButtonOperator.setVisible(false);
        enableField();

    }

    @Override
    public void setParametres(UICrumbsRequest request) {
        id.setText("" + request.getId());
        datelbl.setText(request.getDateOfCreation().toString());
        state.setText(request.getState());
        clAddress.setText(request.getUicrumbsClient().getAdress());
        clMail.setText(request.getUicrumbsClient().getMail());
        clName.setText(request.getUicrumbsClient().getName());

        if (request.getRequestInfo() != null)
            requestInfo.setText(request.getRequestInfo());
        else
            requestInfo.setText("");

        if (request.getActualTimeOfWork() != null)
            timeRequired.setText("" + request.getActualTimeOfWork());
        else
            timeRequired.setText("");
        //timeRequired.setText(request.getActualTimeOfWork().toString());

    }

    @Override
    public Widget asWidget() {
        return this;
    }
}
